//auto gen by paipai.java.augogen ver 3.0.0
//author skyzhuang
//source idl: com.icson.deal.idl.ShoppingCartDao.java


#ifndef ICSON_DEAL_SHOPPINGCART_BO_CDELSHOPPINGCARTOBJECT_BY_AUTOGEN_V5_H
#define ICSON_DEAL_SHOPPINGCART_BO_CDELSHOPPINGCARTOBJECT_BY_AUTOGEN_V5_H


#include "app_platform/intf_serializable.h"
#include <string>
#include <iostream>


namespace icson
{
namespace deal
{
namespace shoppingcart
{
namespace bo
{


class CDelShoppingcartObject : public ISerializable
{
	public:
		std::string m_sLastErrMsg;///<错误信息
		/**
		 * 协议版本号
		 *
		 * 版本 >= 0
		 */
		uint32_t dwVersion;

		/**
		 * 版本 >= 0
		 */
		uint8_t cVersion_u;

		/**
		 * 商品ID
		 *
		 * 版本 >= 0
		 */
		uint64_t ddwProductId;

		/**
		 * 版本 >= 0
		 */
		uint8_t cProductId_u;

		/**
		 * 促销规则ID
		 *
		 * 版本 >= 0
		 */
		uint64_t ddwPromotionId;

		/**
		 * 版本 >= 0
		 */
		uint8_t cPromotionId_u;




	public:
		CDelShoppingcartObject():
		dwVersion(0),
		cVersion_u(0),
		ddwProductId(0),
		cProductId_u(0),
		ddwPromotionId(0),
		cPromotionId_u(0) {}
		CDelShoppingcartObject& operator = (const CDelShoppingcartObject& obj){

			this->dwVersion = obj.dwVersion;
			this->cVersion_u = obj.cVersion_u;
			this->ddwProductId = obj.ddwProductId;
			this->cProductId_u = obj.cProductId_u;
			this->ddwPromotionId = obj.ddwPromotionId;
			this->cPromotionId_u = obj.cPromotionId_u;
			return *this;
		}

	public:


		/**
		 * 是否设置协议版本号了
		 * 
		 * @param uint32_t:dwVersion
		 *  
		 * 
		 */
		 bool  IsVersionSet() const{
				 return  cVersion_u != 0;
		}


		/**
		 * 获取uflag协议版本号了
		 * 
		 * @param uint32_t:dwVersion
		 *  
		 * 
		 */
		 const uint8_t   GetVersionUFlag() const{
				 return  cVersion_u;
		}


		/**
		 * 设置协议版本号
		 * 
		 * @param uint32_t:dwVersion
		 *  
		 * 
		 */
		 void  SetVersion( const uint32_t& sVal, uint8_t cUFlag=1){
				dwVersion = sVal;
				cVersion_u = cUFlag;
		}


		/**
		 * 获取协议版本号
		 * 
		 * @return dwVersion value 类型为:uint32_t
		 * 
		 */
		 const uint32_t&  GetVersion() const {
				return dwVersion;
		}


		/**
		 * 设置
		 * 
		 * 此字段的版本 >= 1
		 * @param uint8_t:cVersion_u
		 *  
		 * 
		 */
		 void  SetVersion_u( const uint8_t& sVal){
				cVersion_u = sVal;
		}


		/**
		 * 获取
		 * 
		 * @return cVersion_u value 类型为:uint8_t
		 * 
		 */
		 const uint8_t&  GetVersion_u() const {
				return cVersion_u;
		}


		/**
		 * 是否设置商品ID了
		 * 
		 * @param uint64_t:ddwProductId
		 *  
		 * 
		 */
		 bool  IsProductIdSet() const{
				 return  cProductId_u != 0;
		}


		/**
		 * 获取uflag商品ID了
		 * 
		 * @param uint64_t:ddwProductId
		 *  
		 * 
		 */
		 const uint8_t   GetProductIdUFlag() const{
				 return  cProductId_u;
		}


		/**
		 * 设置商品ID
		 * 
		 * @param uint64_t:ddwProductId
		 *  
		 * 
		 */
		 void  SetProductId( const uint64_t& sVal, uint8_t cUFlag=1){
				ddwProductId = sVal;
				cProductId_u = cUFlag;
		}


		/**
		 * 获取商品ID
		 * 
		 * @return ddwProductId value 类型为:uint64_t
		 * 
		 */
		 const uint64_t&  GetProductId() const {
				return ddwProductId;
		}


		/**
		 * 设置
		 * 
		 * 此字段的版本 >= 1
		 * @param uint8_t:cProductId_u
		 *  
		 * 
		 */
		 void  SetProductId_u( const uint8_t& sVal){
				cProductId_u = sVal;
		}


		/**
		 * 获取
		 * 
		 * @return cProductId_u value 类型为:uint8_t
		 * 
		 */
		 const uint8_t&  GetProductId_u() const {
				return cProductId_u;
		}


		/**
		 * 是否设置促销规则ID了
		 * 
		 * @param uint64_t:ddwPromotionId
		 *  
		 * 
		 */
		 bool  IsPromotionIdSet() const{
				 return  cPromotionId_u != 0;
		}


		/**
		 * 获取uflag促销规则ID了
		 * 
		 * @param uint64_t:ddwPromotionId
		 *  
		 * 
		 */
		 const uint8_t   GetPromotionIdUFlag() const{
				 return  cPromotionId_u;
		}


		/**
		 * 设置促销规则ID
		 * 
		 * @param uint64_t:ddwPromotionId
		 *  
		 * 
		 */
		 void  SetPromotionId( const uint64_t& sVal, uint8_t cUFlag=1){
				ddwPromotionId = sVal;
				cPromotionId_u = cUFlag;
		}


		/**
		 * 获取促销规则ID
		 * 
		 * @return ddwPromotionId value 类型为:uint64_t
		 * 
		 */
		 const uint64_t&  GetPromotionId() const {
				return ddwPromotionId;
		}


		/**
		 * 设置
		 * 
		 * 此字段的版本 >= 1
		 * @param uint8_t:cPromotionId_u
		 *  
		 * 
		 */
		 void  SetPromotionId_u( const uint8_t& sVal){
				cPromotionId_u = sVal;
		}


		/**
		 * 获取
		 * 
		 * @return cPromotionId_u value 类型为:uint8_t
		 * 
		 */
		 const uint8_t&  GetPromotionId_u() const {
				return cPromotionId_u;
		}

		virtual bool Serialize(CByteStreamNetwork& bs){
		
			uint32_t dwMyLen = 0;
			if(bs.isStoring()) //for write in buffer
			{
				//can not larger than 1 M.
				CByteStreamNetwork bsDummy(NULL, 1024 * 1024, false);
				//bsDummy for precheck the xo size...
				bsDummy.isStoring(true);
				Serialize_i(bsDummy);
				dwMyLen = bsDummy.getWrittenLength();
				bs & dwMyLen;
				Serialize_i(bs);
			}
			else
			{    //for read from buffer
				bs & dwMyLen;
				uint32_t dwReadedLen = bs.getReadLength();
				Serialize_i(bs);
				dwReadedLen = bs.getReadLength() - dwReadedLen;
				// dwReadedLen for the size of xo
				if( dwReadedLen > dwMyLen ){
					return false;
				}
				//go through the unwanted mem position...
				bs.goForward( dwMyLen - dwReadedLen );
			}

			return bs.isGood();
		}

		bool Serialize_i(CByteStreamNetwork& bsTmp){

			bsTmp & dwVersion; // 序列化协议版本号 类型为uint32_t
			bsTmp & cVersion_u; // 序列化 类型为uint8_t
			bsTmp & ddwProductId; // 序列化商品ID 类型为uint64_t
			bsTmp & cProductId_u; // 序列化 类型为uint8_t
			bsTmp & ddwPromotionId; // 序列化促销规则ID 类型为uint64_t
			bsTmp & cPromotionId_u; // 序列化 类型为uint8_t
			return bsTmp.isGood();
		}

		const char* GetLastErrMsg() const{
			return m_sLastErrMsg.c_str();
		}

		bool VerifyDelShoppingcartObject(){

			if(!IsVersionSet()){
				m_sLastErrMsg = "Miss Param:Version";
				return false;
			}

			if(!IsProductIdSet()){
				m_sLastErrMsg = "Miss Param:productId";
				return false;
			}

			if(!IsPromotionIdSet()){
				m_sLastErrMsg = "Miss Param:promotionId";
				return false;
			}
			return true;
		}

		void DumpData(std::ostream& oss) const{
		
			oss<<"[dwVersion:"<<dwVersion<<"] ";
			oss<<"[cVersion_u:"<<(int)cVersion_u<<"] ";
			oss<<"[ddwProductId:"<<ddwProductId<<"] ";
			oss<<"[cProductId_u:"<<(int)cProductId_u<<"] ";
			oss<<"[ddwPromotionId:"<<ddwPromotionId<<"] ";
			oss<<"[cPromotionId_u:"<<(int)cPromotionId_u<<"] ";
		
		}

		// codydeng提供,非常好的dump方法 ^-^  。。。。。
		template<typename T>
		T & DumpPlusData(T& oss){
			oss<<"dwVersion:"<<dwVersion;
			oss<<"cVersion_u:"<<cVersion_u;
			oss<<"ddwProductId:"<<ddwProductId;
			oss<<"cProductId_u:"<<cProductId_u;
			oss<<"ddwPromotionId:"<<ddwPromotionId;
			oss<<"cPromotionId_u:"<<cPromotionId_u;
			return oss;
		}

		// wileywang提供,树形dump方法 ^-^  。。。。。
		void DumpDataTree(std::ostream& os, int ident = 0)const {
			g_pprint(os, "dwVersion", dwVersion, ident);
			g_pprint(os, "cVersion_u", cVersion_u, ident);
			g_pprint(os, "ddwProductId", ddwProductId, ident);
			g_pprint(os, "cProductId_u", cProductId_u, ident);
			g_pprint(os, "ddwPromotionId", ddwPromotionId, ident);
			g_pprint(os, "cPromotionId_u", cPromotionId_u, ident);
		}

/**
 ********************以下信息是每个版本的字段********************
 */

};

}
}
}
}

#endif /* ICSON_DEAL_SHOPPINGCART_BO_CDELSHOPPINGCARTOBJECT_BY_AUTOGEN_V5_H */
